import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
const router = new VueRouter({
  // routes,设置规则
  routes: [
    {
      path: '/',
      // 自动重定向，为默认值常用
      redirect: '/layout',
    },
    {
      name: 'Layout',
      // url链接上匹配的地址
      path: '/layout',
      // component要跳转到那个文件
      component: () => import('@/views/layout.vue'),
      // children配置二级导航，二级导航只会刷新当前所在一级导航对应下的内容
      children: [
        {
          path: '/',
          redirect: '/article'
        },
        {
          name: 'Article',
          path: '/article',
          component: () => import('@/views/article.vue'),
        },
        {
          name: 'Collect',
          path: '/collect',
          component: () => import('@/views/collect.vue'),
        },
        {
          name: 'Like',
          path: '/like',
          component: () => import('@/views/like.vue'),
        },
        {
          name: 'User',
          path: '/user',
          component: () => import('@/views/user.vue'),
        },
      ],
    },
    {
      name:'Detail',
      path:'/detail/:id',
      component: () => import('@/views/article-detail.vue'),
    },
    {
      path: '*',
      component: () => import('@/views/NotFount.vue'),
    },
  ],
})

export default router
